package com.smdk.dsminio.config;

import org.yaml.snakeyaml.Yaml;

import java.io.FileInputStream;
import java.net.URL;
import java.util.Map;

/**
 * @author 神秘的凯
 * @version 1.0
 * @className ReadConfig
 * @date 2018/12/5/005 14:47
 * @Description 描述 读取Yml配置文件
 */
public class ReadConfig {



    public  static Map<String,Object>  getValuesMap(String key){

        try {
            Yaml yaml = new Yaml();
            URL url = ReadConfig.class.getClassLoader().getResource("application.yml");
            if (url != null) {
                //也可以将值转换为Map
                Map<String,Object> map =yaml.load(new FileInputStream(url.getFile()));
                return (Map<String, Object>) map.get(key);
            }else {
                return null;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
